package com.fingard.dsp.bank.reqrespobj.recrefund;

import com.fingard.constant.Format;
import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RequestBase;
import com.fingard.text.StringHelper;

import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;

/**
 * 代扣退款提交请求
 * 
 * @author Cruise
 * @date 2018/10/30
 */
public class ReqRecRefund extends RequestBase {
	/** 商户账号 */
	public String ownAct = "";

	/** 退款流水号 */
	public String refundNo = "";

	/** 原商户订单号 */
	public String oriRdSeq = "";

	/** 原渠道方订单号 */
	public String oriOppOrderNo = "";

	/** 退款金额 (格式：0.00) */
	public String amount = "";

	/** 订单总金额 (格式：0.00) */
	public String totalAmt = "";

	/** 退款原因 */
	public String decription = "";


	/** 原商户订单交易时间 */
	public String oriTransDate;

	/** 订单类型 */
	public String orderType;

	/** 原商户订单交易时间 */
	public String oriPayDate;

    /** 原用户卡号 */
    public String oriPayAct;

	public ReqRecRefund(HashMap<String, String> p_hashMap, ReqRespHeader p_header) throws Exception {
		reqHeader = p_header;

		if (p_hashMap.containsKey("OurBankAccount")) {
			ownAct = p_hashMap.get("OurBankAccount");
			if (StringHelper.isNullOrEmpty(ownAct)) {
				ownAct = "";
			}
		}

		if (p_hashMap.containsKey("RefundNo")) {
			refundNo = p_hashMap.get("RefundNo");
			if (StringHelper.isNullOrEmpty(refundNo)) {
				refundNo = "";
			}
		}
		if (p_hashMap.containsKey("OriRdSeq")) {
			oriRdSeq = p_hashMap.get("OriRdSeq");
			if (StringHelper.isNullOrEmpty(oriRdSeq)) {
				oriRdSeq = "";
			}
		}
		if (p_hashMap.containsKey("OriOppOrderNo")) {
			oriOppOrderNo = p_hashMap.get("OriOppOrderNo");
			if (StringHelper.isNullOrEmpty(oriOppOrderNo)) {
				oriOppOrderNo = "";
			}
		}
		if (p_hashMap.containsKey("Amount")) {
			amount = p_hashMap.get("Amount");
			if (StringHelper.isNullOrEmpty(amount)) {
				amount = "";
			}
		}
		if (p_hashMap.containsKey("TotalAmt")) {
			totalAmt = p_hashMap.get("TotalAmt");
			if (StringHelper.isNullOrEmpty(totalAmt)) {
				totalAmt = "";
			}
		}
		if (p_hashMap.containsKey("Decription")) {
			decription = p_hashMap.get("Decription");
			if (StringHelper.isNullOrEmpty(decription)) {
				decription = "";
			}
		}
		if (p_hashMap.containsKey("PaySentDate")) {
			oriTransDate = p_hashMap.get("PaySentDate");
			if (StringHelper.isNullOrEmpty(oriTransDate)) {
				oriTransDate = "";
			}
		}
		if (p_hashMap.containsKey("OrderType")) {
			orderType = p_hashMap.get("OrderType");
			if (StringHelper.isNullOrEmpty(orderType)) {
				orderType = "";
			}
		}
		if (p_hashMap.containsKey("OriPayDate")) {
			oriPayDate = p_hashMap.get("OriPayDate");
			if (StringHelper.isNullOrEmpty(oriPayDate)) {
				oriPayDate = "";
			}
		}

        if (p_hashMap.containsKey("OriPayAct")) {
            oriPayAct = p_hashMap.get("OriPayAct");
            if (StringHelper.isNullOrEmpty(oriPayAct)) {
                oriPayAct = "";
            }
        }
	}
	
	/**
	 * 获取原商户订单交易时间
	 * 
	 * @return 交易日期
	 * @throws ParseException 日期格式化异常
	 */
	public Date getOriTransDate() throws ParseException {
		if (StringHelper.isNullOrEmpty(oriTransDate)) {
			return new Date();
		}
		return Format.DateTimeFormat.parse(oriTransDate);
	}
}
